var box_choose = (function () {
    // 显示的盒子样式
    var box_attr = {
        style: "border:1px dashed #ff0000;background:rgba(0,0,0,0.2)"
    };
    // 是否已经开始绘制
    var isStart = false;
    // 起始点
    var startPoint = {
        x: 0,
        y: 0
    };
    // 末尾点
    var endPoint = {
        x: 0,
        y: 0
    };
    var box = document.createElement("div");
    box.style.cssText = box_attr.style;
    box.style.position = "absolute";
    function start(x, y) {
        startPoint.x = x;
        startPoint.y = y;
        box.style.left = x + "px";
        box.style.top = y + "px";
        box.style.width = 0 + "px";
        box.style.height = 0 + "px";
        if (!isStart) {
            document.body.appendChild(box);
        }
        isStart = true;
    }
    function move(x, y) {
        endPoint.x = x;
        endPoint.y = y;
        if (startPoint.x > endPoint.x) {
            box.style.left = endPoint.x + "px";
        }
        if (startPoint.y > endPoint.y) {
            box.style.top = endPoint.y + "px";
        }
        box.style.height = Math.abs(y - startPoint.y) + "px";
        box.style.width = Math.abs(x - startPoint.x) + "px";
    }
    function end() {
        box.style.left = 0 + "px";
        box.style.top = 0 + "px";
        box.style.width = 0 + "px";
        box.style.height = 0 + "px";
        // 起始点
        startPoint = {
            x: 0,
            y: 0
        };
        // 末尾点
        endPoint = {
            x: 0,
            y: 0
        };
        isStart = false;
        document.body.removeChild(box);
    }
    return {
        start: start,
        move: move,
        end: end
    };
}());
